<?php

Raise::load('core.RaiseLine');

/**
 * TestCoreRaiseLine
 * testing unit of 'phpraise/core/RaiseLine.php'
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaiseLine extends RaiseTest {

    public static function testClass(){
        self::assertClassExists('RaiseLine');
        self::assertClassExtends('RaiseLine', 'RaiseShape');

        self::assertClassMethod('RaiseLine', 'points');
        self::assertClassMethod('RaiseLine', 'distance');
    }

    public static function testLine1(){
        $line = new RaiseLine();

        self::assertObjectClass($line, 'RaiseLine');
        self::assertObjectClass($line->points(), 'RaiseTypedCollection');
        self::assertStrictEqual($line->points()->type(), 'RaisePoint');
        self::assertStrictEqual($line->distance(), 0);

        $line->points()->add(new RaisePoint(0, 0));
        $line->points()->add(new RaisePoint(3, 4));
        self::assertStrictEqual($line->distance(), 5.0);
        $line->points()->add(new RaisePoint(0, 8));
        self::assertStrictEqual($line->distance(), 10.0);
        $line->points()->add(new RaisePoint(7, 32));
        self::assertStrictEqual($line->distance(), 35.0);
    }

}
